<template>
  <div class="comparelist">
      <titletop :titlename="titlename" :fixedhead="fixedhead"></titletop>
      <screening></screening>
      <div class="content paddingtop2">
        <mt-loadmore  class="loadmore" :bottom-method="loadBottom"   :bottom-all-loaded="allLoaded" bottomPullText="上拉加载" ref="loadmore" >
          <productlist :liststyle="liststyle" :prolistresult="prolistresult"></productlist>
        </mt-loadmore>
      </div>
  </div> 
</template>

<script>
import Mock from 'mockjs'
import productlist from 'components/productlist'
import screening from 'components/screening'
import titletop from 'components/title'

export default {
  name: 'comparelist',
  props : [],
  data () {
    return {
      liststyle:'proin',//初始列表样式
      titlename:'药品对比',
      fixedhead:'fixedhead',//使用fixed标题样式
      allLoaded:false,
      prolistresult: [], //产品列表
      totalprolist: []//所有产品数据
    }
  },
  components: {
      titletop,
      productlist,
      screening
  },
  methods : {
      getprolist(){
          let data = Mock.mock({
              // 属性 list 的值是一个数组，其中含有 10 个元素
              'list|10': [{
                  // 属性 id 是一个自增数，起始值为 1，每次增 1
                  'price':'￥998',
                  'name':'鸿茅药酒 500ml 专治不孕不育 效果显著',
                  'imgUrl|1' : [
                    '../../static/img/yaojiu.png',
                    '../../static/img/rectangle2.png',
                    '../../static/img/rectangle.png'
                  ]
              }]
          });
          this.totalprolist = this.totalprolist.concat(data.list);
          this.prolistresult = data.list;
      },
      loadBottom() {
        console.log("上拉在执行");
        let _this = this;
        setTimeout(() => {
            _this.getprolist();
            _this.prolistresult = _this.totalprolist;
            _this.$refs.loadmore.onBottomLoaded();
        }, 1000);
      },
      gosearchpage(){
        this.$router.push({ name: 'searchpage', query: { historypage: 'druglist' }})
      }
  },
  mounted(){
      let data = Mock.mock({
          // 属性 list 的值是一个数组，其中含有 10 个元素
          'list|10': [{
              // 属性 id 是一个自增数，起始值为 1，每次增 1
              'price':'￥998',
              'name':'鸿茅药酒 500ml 专治不孕不育 效果显著',
              'imgUrl|1' : [
                '../../static/img/yaojiu.png',
                '../../static/img/rectangle2.png',
                '../../static/img/rectangle.png'
              ]
          }]
      });
      this.totalprolist = this.totalprolist.concat(data.list);
      this.prolistresult = data.list;
  }
}

</script>

<style lang="scss" scoped>
  .content{
    
  }
</style>
